package com.example;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileStreamTest {
    
    public void SaveFile(String path, String content){
        try(FileOutputStream fos = new FileOutputStream(path)){
            fos.write(content.getBytes());
        }
        catch (IOException ex){
            ex.printStackTrace();
        }

        try(FileInputStream fis = new FileInputStream(path)){
            byte[] bytes = new byte[512];
            int len = 0;
            while ((len = fis.read(bytes)) != 0) {
                System.out.println(new String(bytes, 0, len));
            }
        }
        catch(IOException ex) {
            ex.printStackTrace();
        }
    }
}
